
<?php
session_start();
header("Content-type: text/html; charset=utf-8");

if(isset($_POST['submit'])){
	include_once("admin/db.php");
	$username = $_POST['username'];
	$password = $_POST['password'];

	$sql = "select * from user where username='$username' and password='$password'";
	$result_set = mysql_query($sql);
	$rows = mysql_num_rows($result_set);
	if($rows==0){
		
		echo '<script>alert("账号或密码错误！");window.location.href="login.php";</script>';
		exit;
	}else{
		$account = mysql_fetch_array($result_set);
		$_SESSION['username'] = $account['username'];
		echo '<script>alert("登录成功！");window.location.href="index.php";</script>';
		exit;
	}

}

?>
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <style>
    body,*{ margin: 0;padding: 0;font-family: "微软雅黑";font-size: 14px;}
	.fl{float: left;}
	.fr{float: right;
	}
	input,select{ height:26px; padding: 0 6px;}
	a{color: #de9a00;text-decoration: none;}
	table { border-collapse:collapse; margin:15px auto;}
	table.xx{width:770px;}
	table.bd{width:370px;}
    table td,table th{border:#ddd solid 1px;padding:7px 5px;text-align:center}
	table td{border:#ddd solid 1px;}
	.top{height:100px;background:#007500;}
	.top .title{height: 100px;
    padding: 0 15px;
    width: 970px;
    background: #007500;
	}

	.top h1{color:#eee;font-size:24px;padding-top: 30px;}
    .w1000{width:800px;margin:0 auto;}
	.log{color:#fff}
	.lefter{    width: 180px;
    background: #588c5e;
    height: 550px;}
	.lefter a.fa{display: block; margin: 5px 0;font-size: 16px; line-height: 40px; background: #659c6b;text-align: center;color: #fff;}
	.lefter a.son{display: block;
    font-size: 14px;
    line-height: 35px;
    margin: 5px 0;
    text-align: center;
    color: #fff;}
	.righter{width: 800px;
    border: #ddd solid 1px;
    margin-top: 0;
    min-height: 500px;}
	.righter .title{line-height: 45px;
    border-bottom: #ddd solid 1px;
    background: #ececec;
    font-size: 16px;
    padding: 0 15px;}
	.search{margin:15px;height:25px;}
	input[type="submit"]{background: #007500;
	
    border: 0;
	height:30px;
	line-height:30px;
    padding: 0 35px;
    color: #fff;}
  </style>

  <title>图书管理系统</title>
 </head>
 <body>
  <div class="top">
	  <div class="w1000 title">
		  <h1 style="margin-left:100px;">图书管理系统</h1>
         
          <div class="log fr">
		  </div>
	  </div>
  </div>

  <div class="main w1000">
    <div class="fr righter">
       <div class="title">
		   普通用户登录    
		     <div align="right" style="margin-top:-45px;"><a href="admin/">后台管理点此处</a></div>
	      </div>
          </br>
          </br>
		  <table class="bd">
		   <form action="login.php" method="post">
			  <tr>
				  <td> 帐 号 ：</td>
				  <td><input type="text" name="username"/></td>
			  </tr>
			  <tr>
				  <td> 密 码 ：</td>
				  <td><input type="password" name="password"/></td>
			  </tr>
			   <tr>
				  <td colspan=2><input type="submit" name="submit" value="登录" onclick="return check()"/></td>
			  </tr>
			</form>  
		  </table>

	  </div>
  </div>
  
 </body>
</html>